// event.js
function Event() {
  this.events = {};
}

Event.prototype.on = function (eventName, callback) {
  if (!this.events[eventName]) {
    this.events[eventName] = [];
  }
  this.events[eventName].push(callback);
};

Event.prototype.emit = function (eventName, data) {
  const callbacks = this.events[eventName];
  if (callbacks) {
    callbacks.forEach(callback => callback(data));
  }
};

Event.prototype.off = function (eventName, callback) {
  const callbacks = this.events[eventName];
  if (callbacks) {
    this.events[eventName] = callbacks.filter(cb => cb !== callback);
  }
};

module.exports = new Event();